Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/map/src/commonTest/kotlin/org/meshtastic/feature/map/layers/MapLayerUriTest.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 2.50 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map.layers

Tff7b72import T7ee787okio.Path.Companion.toPath
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals

T8b949e/**
* These assert compatibility, not correctness in the abstract.
*
* The expected strings are what Android's `Uri.fromFile` produces. A layer's URI is the key its hidden/shown state
* persists under, so drift here silently un-hides every layer a user had hidden.
*/
Tff7b72class T56d364MapLayerUriTest Tb4b4b4{

Tf0883e@Test
Tff7b72fun Td2a8ff`a plain path needs no escaping`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffile:///data/map_layers/route.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/map_layers/route.kmlTa5d6ff"Tb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`a space becomes percent 20`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// The common case, not an edge case: layerFileName keeps spaces, so any multi-word layer name lands here.
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffile:///data/My%20Route.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/My Route.kmlTa5d6ff"Tb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`the unreserved set Android allows is left alone`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffile:///data/a_b-c!d.e~f'g(h)i*j.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/a_b-c!d.e~f'g(h)i*j.kmlTa5d6ff"Tb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`characters Android escapes are escaped`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffile:///data/a%2Cb%26c%2Bd.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/a,b&c+d.kmlTa5d6ff"Tb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`non-latin names round-trip as utf-8 bytes`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3uri Tff7b72= Ta5d6ff"Ta5d6ff/data/Ünïcødé.kmlTa5d6ff"Tb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)

Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6fffile:///data/%C3%9Cn%C3%AFc%C3%B8d%C3%A9.kmlTa5d6ff"Tb4b4b4, Te6edf3uriTb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ff/data/Ünïcødé.kmlTa5d6ff"Tb4b4b4, Te6edf3uriTb4b4b4.Te6edf3toLocalPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`every escaped form decodes back to its own path`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3listOfTb4b4b4(Ta5d6ff"Ta5d6ff/data/My Route.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/a,b&c.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/Ünïcødé.kmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff/data/plain.kmlTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3forEach Tb4b4b4{ Te6edf3path Tff7b72-Tff7b72>
Te6edf3assertEqualsTb4b4b4(Te6edf3pathTb4b4b4, Te6edf3pathTb4b4b4.Te6edf3toPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toFileUriTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toLocalPathTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.2 - Generated in 0.06s